$().ready(function() {
	validateRule();
	laydate({
		elem : '#reimDate',
		type: 'datetime'
	});
});

$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
	$.ajax({
		cache : true,
		type : "POST",
		url : "/fin/payment/payment",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}

function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			receiptDate : {
				required : true
			}
		},
		messages : {
			receiptDate : {
				required : icon + "请选择收款时间"
			}
		}
	})
}


layui.use('upload', function(){
	var upload = layui.upload;
	//执行实例
	var uploadInst = upload.render({
		elem: '#upLoad' //绑定元素
		,url: '/common/sysFile/upload' //上传接口
		,before: function(obj){
			//预读本地文件示例，不支持ie8
			obj.preview(function(index, file, result){
				$('#pic').attr('src', result); //图片链接（base64）
			});
		}
		,done: function(res){
			//上传完毕回调
			console.log(res,"fileName");
			$('#paymentProof').val(res.fileName)
		}
		,error: function(){
			//请求异常回调
		}
	});
})

